<template>
  <div>
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item label="标题" >
        <el-input v-model="title" placeholder="标题" clearable  @clear="handleSearch"></el-input>
      </el-form-item>
      <el-form-item label="录入时间">
        <el-date-picker
            v-model="startTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="起始日期">
        </el-date-picker>
        -
        <el-date-picker
            v-model="endTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleSearch">查询</el-button>
        <el-button @click="handleReset">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="bulletins.list">
      <el-table-column type="index" label="序号"></el-table-column>
      <el-table-column prop="id" label="ID" width="100"></el-table-column>
      <el-table-column label="标题">
        <template slot-scope="scope">
          <i class="el-icon-share"></i>{{scope.row.title}}
        </template>
      </el-table-column>
      <el-table-column prop="admin.adminUsername" label="用户" width="100">
      </el-table-column>
      <el-table-column prop="time" label="发布时间" width="100"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button @click="handleDelete(scope.$index)" size="mini" icon="el-icon-delete">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
        @current-change="handleCurrentChange"
        background
        layout="prev, pager, next,total"
        :current-page="pageNum"
        :page-size="bulletins.pageSize"
        :total="bulletins.total">
    </el-pagination>
  </div>
</template>

<script>
export default {
  name: "ManageBulletinListView",
  data(){
    return{
      title:'',
      startTime:null,
      endTime:null,
      pageNum:1,
      bulletins:{},
    }
  },
  created() {
    this.handleSearch();
    console.log(this.bulletins);
  },
  methods:{
    handleSearch(){
      this.$axios.get("manage/findAllBulletin",{params:{title:this.title,pageNum:this.pageNum,startTime:this.startTime,endTime:this.endTime}}).then(res=>{
       this.bulletins = res.data.pageInfo
        console.log(this.bulletins);
      });
      // this.$axios.post("/manage/findAllBulletin",{params:{pageNum:this.pageNum,startTime:this.startTime,endTime:this.endTime}}).then(res=>{
      //   // this.pageInfo = res.date.pageInfo;
      //   console.log(res.data)
      // });
    },
    handleReset(){

    },
    handleCurrentChange(pageNum) {
      this.pageNum = pageNum;
      this.handleSearch();
    },
    handleDelete(index){

    }
  }
}
</script>

<style scoped>

</style>